import React from 'react';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';

class NotDirectRoute extends React.Component {
  componentWillMount() {
    this._checkDirectAccess();
  }

  componentWillUpdate() {
    this._checkDirectAccess();
  }

  /**
   * 检查路由是否可访问
   * 如果不可访问，则跳转到首页
   * @private
   */
  _checkDirectAccess() {

    console.log(this.props.isAccessble)

   /* if (!this.props.isAccessble)
      this.props.dispatch(push('/'));*/
  }

  render() {
    return (
      <div>{this.props.children}</div>
    );
  }
}

/*NotDirectRoute.propTypes = {
  isAccessble: React.PropTypes.bool.isRequired,
  children: React.PropTypes.node.isRequired,
};*/

export default connect()(NotDirectRoute)
